memory allocation to functions